package com.sky.mapper.common;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.pojo.Dish;
import com.sky.pojo.DishFlavor;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;
import org.springframework.context.annotation.Primary;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     *
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    /**
     * 添加菜品数据
     *
     * @param dish
     */
    @AutoFill
    Integer addDish(Dish dish);

    /**
     * 根据条件查询菜品id
     *
     * @param name
     * @return
     */
    @Select("select id from dish where name = #{name}")
    Long queryDishIdByDishName(String name);


    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);


    boolean deleteDishByIds(List<Long> ids);

    /**
     * 根据菜品id和状态查询数量
     *
     * @param ids
     * @param status
     * @return
     */
    Integer selectCountByIdsAndStatus(@Param("ids") List<Long> ids,
                                      @Param("status") Integer status);

    //批量删除菜品
   /* void deleteByIds(@Param("ids")List<Integer> ids);*/

    /**
     * 根据id查询菜品
     *
     * @param dishId
     * @return
     */
    @Select("select * from dish where id = #{dishId}")
    DishVO findDishById(Long dishId);

    /**
     * 修改菜品
     *
     * @param dish
     */

    @AutoFill
    Integer update(Dish dish);

    /**
     * 根据分类id查询菜品
     *
     * @param dish
     * @return
     */
    /*@Select("select * from dish where category_id = #{categoryId}")*/
    List<Dish> findDishByCategoryId(Dish  dish);



}